package com.education.platform.controller;

import com.education.platform.common.Result;
import com.education.platform.entity.Demand;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 通用数据接口
 *
 * @author education-platform
 * @since 2024-10-10
 */
@Tag(name = "通用数据接口")
@RestController
@RequestMapping("/api/common")
public class CommonController {

    @Operation(summary = "获取科目列表")
    @GetMapping("/subjects")
    public Result<List<String>> getSubjects() {
        List<String> subjects = Arrays.asList(
                "数学", "英语", "物理", "化学", "语文",
                "生物", "历史", "地理", "政治", "计算机",
                "音乐", "美术", "体育", "其他"
        );
        return Result.success(subjects);
    }

    @Operation(summary = "获取年级列表")
    @GetMapping("/grades")
    public Result<List<String>> getGrades() {
        List<String> grades = Arrays.asList(
                "学前班", "小学一年级", "小学二年级", "小学三年级",
                "小学四年级", "小学五年级", "小学六年级",
                "初一", "初二", "初三",
                "高一", "高二", "高三",
                "大学", "成人教育", "其他"
        );
        return Result.success(grades);
    }

    @Operation(summary = "获取授课方式列表")
    @GetMapping("/teaching-types")
    public Result<List<TeachingTypeVO>> getTeachingTypes() {
        List<TeachingTypeVO> teachingTypes = Arrays.stream(Demand.TeachingType.values())
                .map(type -> new TeachingTypeVO(type.getDescription()))
                .collect(Collectors.toList());
        return Result.success(teachingTypes);
    }

    /**
     * 授课方式VO
     */
    @Data
    @AllArgsConstructor
    public static class TeachingTypeVO {
        /**
         * 值：ONLINE/OFFLINE/BOTH
         */
        private String value;
    }
}
